//package com.ruoyi.monitoring.controller;
//
//import com.ruoyi.common.annotation.Log;
//import com.ruoyi.common.core.controller.BaseController;
//import com.ruoyi.common.core.domain.AjaxResult;
//import com.ruoyi.common.core.page.TableDataInfo;
//import com.ruoyi.common.enums.BusinessType;
//import com.ruoyi.common.utils.poi.ExcelUtil;
//import com.ruoyi.monitoring.domain.HealthMonitoring;
//import com.ruoyi.monitoring.service.IHealthMonitoringService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.*;
package com.ruoyi.monitoring.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.monitoring.domain.HealthMonitoring;
import com.ruoyi.monitoring.service.IHealthMonitoringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 健康监测Controller
 *
 * @author ruoyi
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/monitoring/monitoring")
public class HealthMonitoringController extends BaseController
{
    @Autowired
    private IHealthMonitoringService healthMonitoringService;

    /**
     * 查询健康监测列表
     */
    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthMonitoring healthMonitoring)
    {
        startPage();
        List<HealthMonitoring> list = healthMonitoringService.selectHealthMonitoringList(healthMonitoring);
        return getDataTable(list);
    }

    /**
     * 导出健康监测列表
     */
    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:export')")
    @Log(title = "健康监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthMonitoring healthMonitoring)
    {
        List<HealthMonitoring> list = healthMonitoringService.selectHealthMonitoringList(healthMonitoring);
        ExcelUtil<HealthMonitoring> util = new ExcelUtil<HealthMonitoring>(HealthMonitoring.class);
        util.exportExcel(response, list, "健康监测数据");
    }

    /**
     * 获取健康监测详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:query')")
    @GetMapping(value = "/{monitoringId}")
    public AjaxResult getInfo(@PathVariable("monitoringId") Long monitoringId)
    {
        return success(healthMonitoringService.selectHealthMonitoringByMonitoringId(monitoringId));
    }

    /**
     * 新增健康监测
     */
    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:add')")
    @Log(title = "健康监测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthMonitoring healthMonitoring)
    {
        return toAjax(healthMonitoringService.insertHealthMonitoring(healthMonitoring));
    }

    /**
     * 修改健康监测
     */
    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:edit')")
    @Log(title = "健康监测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthMonitoring healthMonitoring)
    {
        return toAjax(healthMonitoringService.updateHealthMonitoring(healthMonitoring));
    }

    /**
     * 删除健康监测
     */
    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:remove')")
    @Log(title = "健康监测", businessType = BusinessType.DELETE)
    @DeleteMapping("/{monitoringIds}")
    public AjaxResult remove(@PathVariable Long[] monitoringIds)
    {
        return toAjax(healthMonitoringService.deleteHealthMonitoringByMonitoringIds(monitoringIds));
    }
}


//
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//
///**
// * 健康监测Controller
// *
// * @author ruoyi
// * @date 2025-01-06
// */
//@RestController
//@RequestMapping("/monitoring/monitoring")
//public class HealthMonitoringController extends BaseController
//{
//    @Autowired
//    private IHealthMonitoringService healthMonitoringService;
//
//    /**
//     * 查询健康监测列表
//     */
//    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(HealthMonitoring healthMonitoring)
//    {
//        startPage();
//        List<HealthMonitoring> list = healthMonitoringService.selectHealthMonitoringList(healthMonitoring);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出健康监测列表
//     */
//    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:export')")
//    @Log(title = "健康监测", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, HealthMonitoring healthMonitoring)
//    {
//        List<HealthMonitoring> list = healthMonitoringService.selectHealthMonitoringList(healthMonitoring);
//        ExcelUtil<HealthMonitoring> util = new ExcelUtil<HealthMonitoring>(HealthMonitoring.class);
//        util.exportExcel(response, list, "健康监测数据");
//    }
//
//    /**
//     * 获取健康监测详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:query')")
//    @GetMapping(value = "/{monitoringId}")
//    public AjaxResult getInfo(@PathVariable("monitoringId") Long monitoringId)
//    {
//        return success(healthMonitoringService.selectHealthMonitoringByMonitoringId(monitoringId));
//    }
//
//    /**
//     * 新增健康监测
//     */
//    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:add')")
//    @Log(title = "健康监测", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody HealthMonitoring healthMonitoring)
//    {
//        return toAjax(healthMonitoringService.insertHealthMonitoring(healthMonitoring));
//    }
//
//    /**
//     * 修改健康监测
//     */
//    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:edit')")
//    @Log(title = "健康监测", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody HealthMonitoring healthMonitoring)
//    {
//        return toAjax(healthMonitoringService.updateHealthMonitoring(healthMonitoring));
//    }
//
//    /**
//     * 删除健康监测
//     */
//    @PreAuthorize("@ss.hasPermi('monitoring:monitoring:remove')")
//    @Log(title = "健康监测", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{monitoringIds}")
//    public AjaxResult remove(@PathVariable Long[] monitoringIds)
//    {
//        return toAjax(healthMonitoringService.deleteHealthMonitoringByMonitoringIds(monitoringIds));
//    }
//}
